
import axios from '@/utils/request'
import store from '@/store'

/**
 *  获取用户频道
 */
export const getUserChannerls = () => axios({
  url: '/v1_0/user/channels',
  headers: {
    Authorization: 'Bearer ' + store.state.user.token.token
  }
})

/**
 *  获取全部频道
 */
export const getChannerls = () => axios({
  url: '/v1_0/channels',
  headers: {
    Authorization: 'Bearer ' + store.state.user.token.token
  }
})

/**
 * 添加用户频道
 * @param {*} channels 用户ID
 */
export const setUserChannels = (channels) => {
  return axios({
    method: 'PATCH',
    url: '/v1_0/user/channels',
    headers: {
      Authorization: 'Bearer ' + store.state.user.token.token
    },
    data: {
      channels
    }
  })
}

/**
 * 删除用户频道
 * @param {*} target 需要删除的用户频道id
 */
export const delUserChannels = (target) => axios({
  method: 'DELETE',
  headers: {
    Authorization: 'Bearer ' + store.state.user.token.token
  },
  url: '/v1_0/user/channels/' + target
})
